/*
 * This file is part of "Deathwatch Ammo Counter for Android".
 *
 * "Deathwatch Ammo Counter for Android" is free software: you can redistribute
 * it and/or modify it under the terms of the GNU General Public License as 
 * published by the Free Software Foundation, either version 3 of the License, 
 * or (at your option) any later version.
 *
 * "Deathwatch Ammo Counter for Android" is distributed in the hope that it 
 * will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 
 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General 
 * Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with "Deathwatch Ammo Counter for Android".  
 * If not, see <http://www.gnu.org/licenses/>.
 * 
 */
package com.TikiiTorch.Deathwatch.AmmoCounter;

import android.os.Parcel;
import android.os.Parcelable;
import android.util.Log;

public class Ammunition implements Parcelable {

	private String name;

	private String effect;

	/**
	 * Creates an instance of Ammunition
	 * 
	 * @param name
	 *            The name of the Ammunition
	 * @param effect
	 *            The effect of the Ammunition
	 */
	public Ammunition(String name, String effect) {
		this.name = name;
		this.effect = effect;
	}

	public Ammunition(Parcel source) {
		/*
		 * Reconstruct from parcel
		 */
		Log.d(C.TAG, "Constructing from parcel");
		name = source.readString();
		effect = source.readString();
	}

	/**
	 * Gets the name of this Ammunition
	 * 
	 * @return The name of this Ammunition
	 */
	public String getName() {
		return this.name;
	}

	/**
	 * Gets the effect of this Ammunition
	 * 
	 * @return The effect this Ammunition gives
	 */
	public String getEffect() {
		return this.effect;
	}

	@Override
	public String toString() {
		return this.name;
	}

	@Override
	public int describeContents() {
		return this.hashCode();
	}

	@Override
	public void writeToParcel(Parcel dest, int flags) {
		Log.d(C.TAG, "writeToParcel..." + flags);

		dest.writeString(name);
		dest.writeString(effect);

	}

	public static final Parcelable.Creator<Ammunition> CREATOR = new Parcelable.Creator<Ammunition>() {
		public Ammunition createFromParcel(Parcel source) {
			return new Ammunition(source);
		}

		public Ammunition[] newArray(int size) {
			return new Ammunition[size];
		}
	};

}
